package org.JQbitorrentClinet.base;

import org.JQbitorrentClinet.QBitorrentConnectionInfo;
import org.JQbitorrentClinet.base.BaseApiProcesser;
import org.JQbitorrentClinet.interfaces.AuthenticationProxy;
import org.JQbitorrentClinet.request.authentication.LoginParam;
import org.JQbitorrentClinet.request.authentication.LogoutParam;

public abstract class BaseProxy extends BaseApiProcesser implements AuthenticationProxy {

    public BaseProxy(QBitorrentConnectionInfo connectionInfo) {
        super(connectionInfo);
    }

    @Override
    public boolean login() {
        LoginParam loginParam = LoginParam.builder()
                .username(connectionInfo.getUsername())
                .password(connectionInfo.getPassword())
                .build();
        process(loginParam, connectionInfo);

        return true;
    }

    @Override
    public boolean logout() {
        LogoutParam logoutParam = LogoutParam.builder().build();
        process(logoutParam, connectionInfo);

        return true;
    }
}
